package com.xdemo.personal.async;

import com.xdemo.manager.IAsyncWork;
import com.xdemo.manager.IMemcacheManager;
import com.xdemo.personal.model.Player;
import com.xdemo.personal.server.pool.EManager;
import com.xdemo.personal.server.pool.ManagerPool;
import com.xdemo.personal.socketserver.msg.StoreSuccessMsg;

/**
 * 
 * @author qianwp
 *
 */
public class StoreWork implements IAsyncWork {
	
	private int value;
	
	private Player player;

	public StoreWork(Player player,int value) {
		this.player = player;
		this.value = value;
	}
	
	@Override
	public void preAction() {

	}

	@Override
	public void doAction() {
		IMemcacheManager _manager = (IMemcacheManager)ManagerPool.getManager(EManager.Memcache);
		_manager.set("object" + value, (long)value * (long)value);
	}

	@Override
	public void afterAction() {
		StoreSuccessMsg _msg = new StoreSuccessMsg();
		_msg.setStoreKey(value);
		player.sendMessage(_msg);
	}

}
